package com.jxau.mapper;

import com.jxau.entity.User;
import com.jxau.entity.view.FollowerAndFansNum;
import com.jxau.entity.view.Liker;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;

public interface UserMapper {
    /**
     * 登录
     * @param id
     * @param password
     * @return 返回该用户权限
     */
    Integer queryByIdAndPwd (@Param("id") String id, @Param("password")String password);
    /**
     * 查询用户头像
     * 首页需要展示
     * @param id
     * @return
     */
    String queryHeadPhotoById(String id);

    /**
     * 根据id查询用户信息
     * @param uid
     * @return
     */
    User queryUserById(String uid);
    /**
     * 取消点赞操作
     * @param articleId
     * @param uid
     */
    void doUnLike(@Param("articleId") Integer articleId,@Param("uid") String uid);

    /**
     * 点赞操作
     * @param articleId
     * @param uid
     */
    void doLike(@Param("articleId") Integer articleId,@Param("uid") String uid);

    /**
     * 收藏操作
     * @param articleId
     * @param uid
     */
    void doCollect(@Param("articleId") Integer articleId,@Param("uid") String uid);
    /**
     * 取消收藏操作
     * @param articleId
     * @param uid
     */
    void doUnCollect(@Param("articleId") Integer articleId,@Param("uid") String uid);
    //-------------------------------------------------------------------------------
    /**
     * 取消点赞操作(评论)
     * @param commentId
     * @param uid
     */
    void doUnLikeForComment(@Param("commentId") Integer commentId,@Param("uid") String uid);

    /**
     * 点赞操作(评论)
     * @param commentId
     * @param uid
     */
    void doLikeForComment(@Param("commentId") Integer commentId,@Param("uid") String uid);

    /**
     * 根据uid查找用户所有信息
     * @param uid
     * @return
     */
    User queryUserInfoById(String uid);

    //查询全部用户
    List<User> getAllUsers();

    /**
     * 更改用户头像的所在地址
     * @param uid 用户id
     * @param newFileName 新头像文件名
     */
    void updateHeadPhoto(@Param("uid") String uid,@Param("newFileName") String newFileName);

    /**
     * 查询该用户的头像文件地址
     * @param uid
     * @return
     */
    String selectHeadPhoto(String uid);
    User selectByPrimaryKey(String id);

    List<User> findUserByName(String name);

    int updateUser(User user);

    int deleteByPrimaryKey(String id);

    int addUser(User user);

    User existsUser(@Param("id") String id,@Param("password") String password);

    void updateUserInfo(User user);

    ArrayList<User> queryFollowers(String uid);

    ArrayList<User> queryFans(String uid);

    FollowerAndFansNum queryFollowerAndFansNum(String uid);

    int queryIsFollow(@Param("uid") String uid, @Param("otherUid") String otherUid);

    void cancelFollow(@Param("uid") String uid, @Param("otherUid") String otherUid);

    void followUser(@Param("uid") String uid, @Param("otherUid") String otherUid);

    int queryUserIsExistByUid(String uid);

    void insertUser(@Param("uid") String uid, @Param("password") String password);

    Integer findNewCommentNum(String uid);

    Integer findNewArticleLikeNum(String uid);

    Integer findNewCommentLikeNum(String uid);

    List<Liker> getNewLikerOfArticle(String uid);

    List<Liker> getNewLikerOfComment(String uid);

    void updateReadFlagOfLikeArticle(String uid);

    void updateReadFlagOfLikeComment(String uid);
}
